package com.rchat.pocmini.session;

import com.airtalkee.sdk.entity.AirContact;
import com.airtalkee.sdk.entity.AirSession;

import java.util.List;

/**
 * Created by ljd on 2017/2/6.
 * <p>
 * 会话类，用以表示一路会话的信息，频道会话和临时会话在会话状态均用AirSession类来标示
 */

public class PocAirSession implements PocAirSessionInterface {

    //AirSession实例
    private AirSession airSession;

    //============= SESSION_STATE值 ===========
    //会话不可用
    public static final int SESSION_STATE_IDLE = AirSession.SESSION_STATE_IDLE;
    //会话正在建立中
    public static final int SESSION_STATE_CALLING = AirSession.SESSION_STATE_CALLING;
    //会话进行中
    public static final int SESSION_STATE_DIALOG = AirSession.SESSION_STATE_DIALOG;

    //============= SESSION_TYPE值 ===========
    //临时会话
    public static final int TYPE_DIALOG = AirSession.TYPE_DIALOG;
    //频道会话
    public static final int TYPE_CHANNEL = AirSession.TYPE_CHANNEL;

    //============= MEDIA_STATE值 ===========
    //处于空闲状态
    public static final int MEDIA_STATE_IDLE = AirSession.MEDIA_STATE_IDLE;
    //有人正在讲话
    public static final int MEDIA_STATE_LISTEN = AirSession.MEDIA_STATE_LISTEN;
    //本人正在讲话
    public static final int MEDIA_STATE_TALK = AirSession.MEDIA_STATE_TALK;

    //============= MEDIA_BUTTON_STATE值 ===========
    //讲话按钮处于空闲状态
    public static final int MEDIA_BUTTON_STATE_IDLE = AirSession.MEDIA_BUTTON_STATE_IDLE;
    //讲话按钮处于连接状态(频道连接时的状态)
    public static final int MEDIA_BUTTON_STATE_CONNECTING = AirSession.MEDIA_BUTTON_STATE_CONNECTING;
    //讲话按钮处于申请状态
    public static final int MEDIA_BUTTON_STATE_REQUESTING = AirSession.MEDIA_BUTTON_STATE_REQUESTING;
    //讲话按钮处于释放状态
    public static final int MEDIA_BUTTON_STATE_RELEASING = AirSession.MEDIA_BUTTON_STATE_RELEASING;
    //讲话按钮处于排队状态
    public static final int MEDIA_BUTTON_STATE_QUEUE = AirSession.MEDIA_BUTTON_STATE_QUEUE;
    //讲话按钮处于讲话状态
    public static final int MEDIA_BUTTON_STATE_TALKING = AirSession.MEDIA_BUTTON_STATE_TALKING;


    //============= SESSION_RELEASE_REASON值 ===========
    //会话正常挂断
    public static final int SESSION_RELEASE_REASON_GENERAL = AirSession.SESSION_RELEASE_REASON_GENERAL;
    //通话过程是遇到服务器异常或连接不到服务器
    public static final int SESSION_RELEASE_REASON_ERROR = AirSession.SESSION_RELEASE_REASON_ERROR;
    //被叫方不在线
    public static final int SESSION_RELEASE_REASON_NOTREACH = AirSession.SESSION_RELEASE_REASON_NOTREACH;
    //被叫方忙
    public static final int SESSION_RELEASE_REASON_BUSY = AirSession.SESSION_RELEASE_REASON_BUSY;
    //呼叫被禁止
    public static final int SESSION_RELEASE_REASON_FORBIDDEN = AirSession.SESSION_RELEASE_REASON_FORBIDDEN;
    //被叫方拒绝呼叫
    public static final int SESSION_RELEASE_REASON_REJECTED = AirSession.SESSION_RELEASE_REASON_REJECTED;
    //被叫方无应答
    public static final int SESSION_RELEASE_REASON_NOANSWER = AirSession.SESSION_RELEASE_REASON_NOANSWER;
    //用户的心跳周期已过期，需要重新登录
    public static final int SESSION_RELEASE_REASON_EXPIRE = AirSession.SESSION_RELEASE_REASON_EXPIRE;
    //呼叫频率过高
    public static final int SESSION_RELEASE_REASON_FREQUENTLY = AirSession.SESSION_RELEASE_REASON_FREQUENTLY;
    //网络错误
    public static final int SESSION_RELEASE_REASON_NETWORK_TERMINATE = AirSession.SESSION_RELEASE_REASON_NETWORK_TERMINATE;


    public PocAirSession() {
        airSession = new AirSession();
    }

    public PocAirSession(String sessionCode, String displayName, int type, byte[] photo, String id, int messageUnReadeCount) {
        airSession = new AirSession(sessionCode, displayName, type, photo, id, messageUnReadeCount);
    }

    /**
     * 获取AirSession实例
     *
     * @return airSession
     */
    @Override
    public AirSession getAirSession() {
        return airSession;
    }

    /**
     * 获取会话索引
     *
     * @return 会话索引
     */
    @Override
    public int getSessionIndex() {
        return airSession.getSessionIndex();
    }

    /**
     * 获取会话代码
     *
     * @return 会话代码
     */
    @Override
    public String getSessionCode() {
        return airSession.getSessionCode();
    }

    /**
     * 获取会话状态
     *
     * @return 会话状态值（参考SESSION_STATE）
     */
    @Override
    public int getSessionState() {
        return airSession.getSessionState();
    }

    /**
     * 获取会话类型
     *
     * @return 会话类型值（参考SESSION_TYPE）
     */
    @Override
    public int getSessionType() {
        return airSession.getType();
    }

    /**
     * 获取会话名称，一般为主叫人的名字或频道名称
     *
     * @return 会话名称
     */
    @Override
    public String getSessionName() {
        return airSession.getDisplayName();
    }

    /**
     * 获取会话中当前讲话状态
     *
     * @return 当前讲话状态值(参考MEDIA_STATE)
     */
    @Override
    public int getMediaState() {
        return airSession.getMediaState();
    }

    /**
     * 获取会话中“讲话按钮”当前对应的状态
     *
     * @return “讲话按钮”当前对应的状态值（参考MEDIA_BUTTON_STATE）
     */
    @Override
    public int getMediaButtonState() {
        return airSession.getMediaButtonState();
    }

    /**
     * 获取会话中所有成员
     *
     * @return
     */
    @Override
    public List<AirContact> getMemberAll() {
        return airSession.getMemberAll();
    }

    /**
     * 获取正在讲话的人
     *
     * @return
     */
    @Override
    public AirContact getSpeaker() {
        return airSession.getSpeaker();
    }


}
